import router from '@/router'
import store from '@/store'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
// 网站白名单
let whitePage = ['/login', '404']
router.beforeEach((to, from, next) => {
  NProgress.start()
  let _token = store.getters.token
  if (!_token) {
    if (whitePage.includes(to.path)) {
      next()
    } else {
      next('/login')
    }
  } else {
    if (to.path === '/login') {
      next('/')
    } else {
      next()
    }
  }
  NProgress.done()
  // next()
})
router.afterEach((to, from) => {
  NProgress.done()
})
